package com.noob.assessment.web.exception;

import com.noob.assessment.api.ApiResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: zhengwq
 * datetime: 2020-04-18 23:48
 * description: 全局异常处理器
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public ApiResponse exceptionHandle(Exception e) {
        return ApiResponse.error(e.getMessage());
    }

}